package ttsolver.input;

import ttsolver.enums.TrackType;

public class Track {
	private Node nodeOne;
	private Node nodeTwo;
	private TrackType type;
	private double length;
	private int milepost;

	public Track(Node nodeOne, Node nodeTwo) {
		if (nodeOne.getId() < nodeTwo.getId()) {
			this.nodeOne = nodeOne;
			this.nodeTwo = nodeTwo;
		} else {
			this.nodeOne = nodeTwo;
			this.nodeTwo = nodeOne;
		}
		length = 0;
		milepost = -1;
	}

	public Node getNodeOne() {
		return nodeOne;
	}

	public void setNodeOne(Node nodeOne) {
		this.nodeOne = nodeOne;
	}

	public Node getNodeTwo() {
		return nodeTwo;
	}

	public void setNodeTwo(Node nodeTwo) {
		this.nodeTwo = nodeTwo;
	}

	public TrackType getType() {
		return type;
	}

	public void setType(TrackType type) {
		this.type = type;
	}

	public double getLength() {
		return length;
	}

	public void setLength(double length) {
		this.length = length;
	}
	
	public int getMilepost() {
		return milepost;
	}

	public void setMilepost(int milepost) {
		this.milepost = milepost;
	}

	public long key() {
		final long prime = 31;
		long result = 1;
		result = prime * result
				+ ((nodeOne == null) ? 0 : nodeOne.getId().intValue());
		result = prime * result
				+ ((nodeTwo == null) ? 0 : nodeTwo.getId().intValue());
		return result;
	}
}
